export default ({ request, serviceForMock, mock, faker }) => {

  // Mock数据配置
  mock.onGet('/device/electric/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 112,
        pageSize: 10,
        totalPage: 12,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          deviceId: `E${String(index + 1).padStart(4, '0')}`,
          roomNumber: `10${index + 1}`,
          tenantName: faker.name.findName(),
          currentReading: faker.random.number({ min: 1000, max: 9999 }),
          lastReading: faker.random.number({ min: 500, max: 1000 }),
          usage: faker.random.number({ min: 50, max: 200 }),
          status: ['在线', '离线', '故障'][index % 3],
          lastUpdateTime: faker.date.recent().toISOString().replace('T', ' ').split('.')[0]
        }))
      }
    }
  })

  mock.onGet('/device/water/list').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      page: {
        totalCount: 112,
        pageSize: 10,
        totalPage: 12,
        currPage: 1,
        list: Array.from({ length: 10 }, (_, index) => ({
          id: index + 1,
          deviceId: `W${String(index + 1).padStart(4, '0')}`,
          roomNumber: `10${index + 1}`,
          tenantName: faker.name.findName(),
          currentReading: faker.random.number({ min: 100, max: 999 }),
          lastReading: faker.random.number({ min: 50, max: 100 }),
          usage: faker.random.number({ min: 5, max: 50 }),
          status: ['在线', '离线', '故障'][index % 3],
          lastUpdateTime: faker.date.recent().toISOString().replace('T', ' ').split('.')[0]
        }))
      }
    }
  })

  // 设备状态统计数据
  mock.onGet('/device/statistics').reply(200, {
    code: 0,
    msg: 'success',
    data: {
      electric: {
        online: 112,
        offline: 4,
        total: 116
      },
      water: {
        online: 112,
        offline: 4,
        total: 116
      },
      gateway: {
        online: 112,
        offline: 4,
        total: 116
      },
      fourG: {
        online: 112,
        offline: 4,
        total: 116
      }
    }
  })

  return {
    // 电表管理
    device_electric_list(params = {}) {
      return request({
        url: '/device/electric/list',
        params
      })
    },

    device_electric_info(params = {}) {
      return request({
        url: '/device/electric/info/' + params.id,
        params
      })
    },

    device_electric_save(data = {}) {
      return request({
        url: '/device/electric/save',
        method: 'post',
        data
      })
    },

    device_electric_update(data = {}) {
      return request({
        url: '/device/electric/update',
        method: 'post',
        data
      })
    },

    device_electric_delete(data = {}) {
      return request({
        url: '/device/electric/delete',
        method: 'post',
        data
      })
    },

    // 水表管理
    device_water_list(params = {}) {
      return request({
        url: '/device/water/list',
        params
      })
    },

    device_water_info(params = {}) {
      return request({
        url: '/device/water/info/' + params.id,
        params
      })
    },

    device_water_save(data = {}) {
      return request({
        url: '/device/water/save',
        method: 'post',
        data
      })
    },

    device_water_update(data = {}) {
      return request({
        url: '/device/water/update',
        method: 'post',
        data
      })
    },

    device_water_delete(data = {}) {
      return request({
        url: '/device/water/delete',
        method: 'post',
        data
      })
    },

    // 设备统计
    device_statistics(params = {}) {
      return request({
        url: '/device/statistics',
        params
      })
    }
  }
}

